package strategy.improve;

/**
 * @Author shenhan
 * @Date: 2020/4/12 17:17
 * @Description:
 */
public abstract class Duck {
    FlyBehavior flyBehavior;

    public Duck() {
    }

    abstract void display();

    void quack() {
        System.out.println("嘎嘎叫");
    }
    void swim() {
        System.out.println("游泳");
    }
    void fly() {
        if (flyBehavior != null) {
            flyBehavior.fly();
        }
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }
}
